let toTop=document.querySelector(".toTop");
toTop.onclick=function(){
    let y=window.scrollY;
    let timer=setInterval(function(){
        y-=100;
        window.scrollTo(0,y);
        if(y<=0){
            clearInterval(timer);
        };
    },200)
}
window.onscroll=function(){
    if(window.scrollY>=300){
        toTop.style.display="block";
    }else{
        toTop.style.display="none";
    }
}